import Page
from Page import Service
from Base.Base import Base
from selenium.webdriver.common.by import By


class ServiceMyReservationPage(Base):
    """
    我的预约页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.reservation_home_btn = (By.XPATH, Service.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.reservation_back_btn = (By.XPATH, Service.RESOURCE_ID.format('ivBack'))

        # 已提交按钮
        self.reservation_submitted_tab_btn = (By.XPATH, Page.TEXT.format("已提交"))

        # 已确认按钮
        self.reservation_sure_tab_btn = (By.XPATH, Page.TEXT.format("已确认"))

        # 已取消按钮
        self.reservation_cancel_tab_btn = (By.XPATH, Page.TEXT.format("已取消"))

        # 全部按钮
        self.reservation_all_tab_btn = (By.XPATH, Page.TEXT.format("全部"))

        # 没有预约文案
        self.reservation_no_appointment_text = (By.XPATH, Service.RESOURCE_ID.format("notdata_text"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.reservation_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.reservation_back_btn)

    def click_submitted_tab(self):
        """
        点击已提交按钮

        :return:None
        """
        self.click_element(self.reservation_submitted_tab_btn)

    def get_submitted_tab(self):
        """
        获取已提交按钮

        :return: 获取元素
        """
        return self.find_element_o(self.reservation_submitted_tab_btn)

    def click_sure_tab(self):
        """
        点击已确认按钮

        :return:None
        """
        self.click_element(self.reservation_submitted_tab_btn)

    def get_sure_tab(self):
        """
        获取已确认按钮

        :return: 获取元素
        """
        return self.find_element_o(self.reservation_sure_tab_btn)

    def click_cancel_tab(self):
        """
        点击已取消按钮

        :return:None
        """
        self.click_element(self.reservation_cancel_tab_btn)

    def get_cancel_tab(self):
        """
        获取已取消按钮

        :return: 获取元素
        """
        return self.find_element_o(self.reservation_cancel_tab_btn)

    def click_all_tab(self):
        """
        点击全部按钮

        :return:None
        """
        self.click_element(self.reservation_all_tab_btn)

    def get_all_tab(self):
        """
        获取全部按钮

        :return: 获取元素
        """
        return self.find_element_o(self.reservation_all_tab_btn)

    def get_no_appointment(self):
        """
        获取没有预约文案

        :return: 获取元素
        """
        return self.find_element_o(self.reservation_no_appointment_text)

    def is_display_service_my_reservation(self):
        """
        是否进入我的预约页

        :return: bool
        """
        return self.is_display(self.reservation_submitted_tab_btn)
